package com.gistmap.util;

import java.util.List;

/**
 * 定义一个分页对象
 * 
 * @author
 * 
 */
public class Pager<T> {

    private int pageNo;// 当前页码
    private int pageTotal;// 总页码
    private int rowsTotal;// 总条数
    private int pageSize;// 每页显示条数
    private List<T> list;// 返回的数据集合

    public int getPageNo() {
    	
        return pageNo;
    }

    public void setPageNo(int pageNo) {
    	if( pageNo < 1)
    		this.pageNo = 1;
    	else if( pageNo > pageTotal)
    		this.pageNo = pageTotal;
    	else
    		this.pageNo = pageNo;
    }
    
  
    
    public int getPageTotal() {
        return pageTotal;
    }

    public void setPageTotal(int pageTotal) {
        this.pageTotal = pageTotal;
    }

    public int getRowsTotal() {
        return rowsTotal;
    }

    public void setRowsTotal(int rowsTotal) {
        this.rowsTotal = rowsTotal;
        System.out.println();
        pageTotal = rowsTotal % pageSize == 0 ? rowsTotal / pageSize : rowsTotal / pageSize + 1;
        System.out.println("row"+rowsTotal+"pa"+pageTotal);
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }


    @Override
    public String toString() {
        return "Pager [pageNo=" + pageNo + ", pageTotal=" + pageTotal
                + ", rowsTotal=" + rowsTotal + ", pageSize=" + pageSize
                + ", list=" + list + "]";
    }

}